#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=200000;

int max(int a, int b) {
  return a>b ? a : b;
}

int getLen(long long *a, int n) {
  static long long que[maxn+1];
  que[0] = 0;
  for (int i=1; i<=n; i++) {
    if (!que[0] || que[que[0]]<a[i]) {
      que[++que[0]] = a[i];
    } else {
      int pos=1;
      for (int l=1, r=que[0], mid; l<=r; ) {
	mid=(l+r)/2;
	if (que[mid]<a[i]) {
	  pos = mid+1;
	  l = mid+1;
	} else {
	  r = mid-1;
	}
      }
      que[pos] = a[i];
    }
  }
  return que[0];
}

int main() {
  freopen("glo.in", "r", stdin);
  freopen("glo_bf.out", "w", stdout);

  static long long a[maxn+1];
  int n, x;
  scanf("%d %d", &n, &x);
  for (int i=1; i<=n; i++) {
    scanf("%lld", a+i);
  }

  int ans=0;
  for (long long d=-x; d<=x; d++) {
    for (int i=1; i<=n; i++) {
      for (int j=i; j<=n; j++) {
	a[j] += d;
	ans = max(ans, getLen(a, n));
      }
      for (int j=i; j<=n; j++) {
	a[j] -= d;
      }
    }
  }

  printf("%d", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
